import sys
from util import *
from kmeans import *

if(len(sys.argv) < 2):
    sys.stderr.write("falha!\n informe o arquivo com o codebook\n")
    sys.exit() 

codebook_path = sys.argv[1]
cbfile = open(codebook_path)
codebooklst = read_points(cbfile)

img = Image.open(sys.stdin)
pixellist = listOfPixels(img)

histogr = histogram(codebooklst,pixellist)
print_points(sys.stdout,[histogr])

cbfile.close()
